<#escape x as x?html>
<div class="box box-solid box-fusion no-shadow no-border">
    <div class="box-header">
        <div class="col-md-7">
            <h3 class="box-title">&nbsp;</h3>
        </div>
        <div class="box-tools">
            <@y.htmlFuzzySearchListForm "false" "true">
            </@y.htmlFuzzySearchListForm>
        </div>
    </div><!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
        <table class="table table-inner-bordered table-hover">
            <thead>
            <th class="col-md-2 col-lg-2">
                <@s.message "base.auditLog.list.operationType"/>
            </th>
            <th class="col-md-2 col-lg-2">
                <@s.message "base.auditLog.list.operatorAccount"/>
            </th>
            <th class="col-md-2 col-lg-2">
                <@s.message "base.auditLog.list.operatorHost"/>
            </th>
            <th class="col-md-2 col-lg-2">
                <@s.message "base.auditLog.list.operationEntityId"/>
            </th>
            <th class="col-md-2 col-lg-2">
                <@s.message "base.auditLog.list.operationContent"/>
            </th>
            <th class="col-md-2 col-lg-2">
                <@s.message "base.auditLog.list.operationTime"/>
            </th>
            </thead>
            <tbody>
                <#if (page.entities??)&&(page.entities?size>0)>
                    <#list page.entities as record>
                    <tr record-id='${record.id}'>
                        <td class="popup-close">${record.operationType!''}</td>
                        <td class="popup-close">${record.operatorAccount!''}</td>
                        <td class="popup-close">${record.operatorHost!''}</td>
                        <td class="popup-close">${record.operationEntityId!''}</td>
                        <td class="popup-close">${record.operationContent!''}</td>
                        <td class="popup-close">${(record.operationTime?string("yyyy-MM-dd HH:mm:ss"))!''}</td>
                    </tr>
                    </#list>
                </#if>
            </tbody>
        </table>
    </div><!-- /.box-body -->
    <div class="box-footer no-border clearfix">
        <@y.htmlPaginationOverview/>
    </div>
</div><!-- /.box -->
    <@y.htmlModal type="save"/>
<script>
    context.call([
        'core',
        'list',
        'tools',
        'moment',
        'dateRangePicker'
    ], function (core, list, tools, moment, dateRangePicker) {
        list.initFuzzySearchList('/base/auditLog');

        $(".action-export").unbind("click").on("click", function () {
            tools.modalSave({
                title: '导出',
                message: function () {
                    var form = $('<form></form>').addClass('form-horizontal form-fusion');
                    var div = $('<div></div>').addClass('form-group');

                    var content = $('<label class="col-sm-2 control-label">时间范围</label>' +
                            '<div class="col-sm-9">' +
                            '<div class="input-group">' +
                            '<div class="input-group-addon">' +
                            '<i class="fa fa-clock-o"></i>' +
                            '</div>' +
                            '<input class="form-control" type="text" name="dateRange" id="dateRange" ' +
                            'style="cursor:pointer" value="">' +
                            '</div>' +
                            '</div>');
                    form.append(div);
                    div.append(content);

                    return form.prop('outerHTML');
                },
                closable:false,
                onshown: function () {
                    var timeFormat = "YYYY/MM/DD HH:mm:ss";
                    tools.dateRangePicker('#dateRange', {
                        'ranges': {
                            '今天': [
                                moment().format(timeFormat),
                                moment().format(timeFormat)
                            ],
                            '1周': [
                                moment().add(-1, "week").format(timeFormat),
                                moment().format(timeFormat)
                            ],
                            '1个月': [
                                moment().add(-1, "month").format(timeFormat),
                                moment().format(timeFormat)
                            ],
                            '3个月': [
                                moment().add(-3, "month").format(timeFormat),
                                moment().format(timeFormat)
                            ],
                            '6个月': [
                                moment().add(-6, "month").format(timeFormat),
                                moment().format(timeFormat)
                            ],
                            '1年': [
                                moment().add(-1, "year").format(timeFormat),
                                moment().format(timeFormat)
                            ]
                        },
                        'opens': 'center'
                    });
                },
                callback: function (result) {
                    if (result) {
                        var urls = new core.Urls('/base/auditLog');
                        var dateRange = $('#dateRange').val().replace(/ - /g,'_').replace(/\//g,'-').replace(/ /g,'T');
                        window.open(urls.exportXls() + '/' + dateRange);
                    }
                }
            })
        })
        ;
    })
</script>
</#escape>